package com.servlet;

import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/demo05.do")
public class Demo05Servlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("Demo05Servlet doGet()");
        String username = req.getParameter("username");
        System.out.println(username);
        //取出在其他Servlet中往该域对象里存的值
        System.out.println(req.getAttribute("u1"));
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("Demo05Servlet doPost()");
        PrintWriter writer = resp.getWriter();
        ServletOutputStream outputStream = resp.getOutputStream();
    }
}
